#set(seoTitle="修改密码")
#@layout()
#define main()
<!--左侧部分 -->
#include("../common/_my_left_side.html")

<div class="col jf-page-main jf-pdr0">
	<div class="jf-panel jf-my-space-pd">
		<div class="jf-panel-body">
			<nav aria-label="breadcrumb " >
			  <ol class="breadcrumb jf-my-breadcrumb">
			    <li class="breadcrumb-item"><a href="/my">我的空间</a></li>
			    <li class="breadcrumb-item active" aria-current="page">修改密码</li>
			  </ol>
			</nav>
			
			<!-- 内容区域  start-->
			<div style="width: 500px; margin: 100px auto;">
			
			<form id="password_update_form" action="/my/setting/updatePassword" method="post">
			  <div class="form-group row">
			    <label for="oldpwd" class="col-sm-2 col-form-label">原密码</label>
			    <div class="col-sm-10">
			      <input type="password" name="oldPassword" autocomplete="off" class="form-control" id="oldpwd" placeholder="请输入原密码">
			    </div>
			  </div>
			  
			  <div class="form-group row">
			    <label for="newpwd" class="col-sm-2 col-form-label">新密码</label>
			    <div class="col-sm-10">
			      <input type="password" name="newPassword" autocomplete="off" class="form-control" id="newpwd" placeholder="请输入新密码">
			    </div>
			  </div>
			  
			  <div class="form-group row">
			    <div class="col-12 text-right">
			      <button type="submit" class="btn btn-primary"><i class="fa fa-check mr-1"></i>确认</button>
			    </div>
			  </div>  
			</form>
			
			</div>
			<!-- 内容区域  end-->
		</div>
	</div>

</div>
#end

#define js()
	<script type="text/javascript" src="/assets/jquery_form/jquery.form.min.js"></script>
	
	<script type="text/javascript" src="/assets/js/my-space-4.0.js"></script>
	<script type="text/javascript" src="/assets/layer/layer/layer.js"></script>

	<script type="text/javascript">
		// 使用 ajax form 提交密码修改表单
		$(document).ready(function() {
			$("#password_update_form").ajaxForm({
				dataType: "json"
				, beforeSubmit: function(formData, jqForm, options) {
				}
				, success: function(ret) {
					if (ret.state == "ok") {
						showOkMsg(ret.msg);
					} else {
						showErrorMsg(ret.msg);
					}
				}
				, error: function(ret) {
					alert(ret.msg);
				}
			});
		});

		function showOkMsg(msg) {
			layer.msg(msg, {
						shift: 0
						, shade: 0.4
						, time: 0
						, offset: "140px"
						, closeBtn: 1
						, shadeClose: false
						,maxWidth: "1000"
					}, function () {
						location.href = "/my";
					}
			);
		}

		function showErrorMsg(msg) {
			layer.msg(msg, {
						shift: 6
						, shade: 0.4
						, time: 0
						, offset: "140px"
						, closeBtn: 1
						, shadeClose: true
						,maxWidth: "1000"
					}, function () {}
			);
		}
	</script>
#end